package cn.wolfcode.p2p.mgrsite.task;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import cn.wolfcode.p2p.business.service.IBidRequestService;

/**
 * 定时器
 * @author Administrator
 *
 */
@Component
public class BidRequestTask implements ApplicationListener<ContextRefreshedEvent>{
	@Autowired
	private IBidRequestService bidRequestService;
	
	/**
	 * 服务器启动就去查询当前时间最近一个小时发布的待发布借款
	 */
	public void onApplicationEvent(ContextRefreshedEvent event) {
		bidRequestService.listUnPublishedRequestInOneHour();
	}
	/**
	 * 每隔一小时查询最近一个小时的发布的待发布借款
	 */
	@Scheduled(cron = "0 0 0/1 * * ? ")
	public void listUnPublishedRequestInOneHour(){
		bidRequestService.listUnPublishedRequestInOneHour();
		
	}
	/**
	 * 每隔一分钟发布队列中当前小于或等于当前分钟的待发布借款
	 */
	@Scheduled(cron = "0 0/1 * * * ? ")
	public void publishedBidRequestPreMinute(){
		bidRequestService.publishedBidRequestPreMinute();
	}


}
